# -*- coding:utf-8 -*-
"""
@Time : 2021/4/14 10:05
@Author: langengel
@Des: 后台基本验证模型
"""
from pydantic import BaseModel, Field
from typing import Optional, List


class AdminLogin(BaseModel):
    """
    管理员登陆
    """
    password: str
    u_phone: str


class PhoneCode(BaseModel):
    """
    发送短信
    """
    phone: str = Field(max_length=11, min_length=11, title="手机号")
    web_code: str = Field(max_length=32, min_length=32, title="访问码")


class CreateRole(BaseModel):
    role_name: str = Field(min_length=2, max_length=10)
    role_status: Optional[bool] = True
    role_desc: Optional[str]


class UpdateRole(BaseModel):
    role_id: int
    role_name: str
    role_desc: Optional[str]
    role_status: bool


class ChangeStatus(BaseModel):
    role_id: int
    role_status: bool


class SetScopes(BaseModel):
    role_id: int
    scopes: List[int]


class CreateUser(BaseModel):
    """
    添加用户
    """
    roles: List[int]
    full_name: str
    u_status: int
    u_phone: str
    remarks: Optional[str] = None


class UpdateAdminUser(BaseModel):
    """
    添加用户
    """
    user_id: int
    roles: List[int]
    full_name: str
    u_status: int
    u_phone: str
    remarks: Optional[str] = None


class WxInfo(BaseModel):
    """
    微信用户信息
    """
    city: str = None,
    country: str = None,
    headimgurl: str = None,
    nickname: str = None,
    openid: str = None,
    province: str = None,
    sex: int = None


class AccountLogin(BaseModel):
    username: str
    password: str


class AddRule(BaseModel):
    rule_name: str
    parent_id: Optional[int] = 0
    scopes: str
    is_check: int
    is_menu: int
    rule_desc: Optional[str] = None
